mini.parse();

function MessageHandler() {
};

MessageHandler.messageGrid = mini.get("messageGrid");
MessageHandler.messageGrid.load();

/**
 * 根据用户权限展示功能按钮
 */
MessageHandler.loadToolbar = function() {
	var array = new Array("member_messages_del", "member_messages_query", "member_messages_refresh");
	var userArr = MiniuiTools.isHasPurview(array);
	
	for (var i = 0; i < userArr.length; i++) {
		mini.get(array[i]).setVisible(userArr[i]);
	}
};
MessageHandler.loadToolbar();

MessageHandler.changeState = function(state) {
	if (!MiniuiTools.hasPurview("member_messages_state")) {
		return;
	}
	
	var rowData = mini.get("messageGrid").getSelected();
	
	$.ajax({
				url : "../../../saveApprove.do",
				type : "POST",
				data : {
					bumId : rowData.bumId,
					state : state,
		        	lslUser: gbOperateUser,
		    		lslAddress: gbOperateIp
				},
				cache : false,
				success : function(text) {
					MessageHandler.messageGrid.reload();
				},
				error : function(jqXHR, textStatus, errorThrown) {
					mini.alert(jqXHR.responseText, "系统提示", null);
					MessageFormHandler.closeCurrentWin();
				}
			});
}

function onActionRenderer(e) {
	var s = '<a class="New_Button" href="javascript:void(0);" onclick="MessageFormHandler.replyMessage();">回复</a>';
	return s;
}

function onCheckBack(e) {
	var k = e.row.bumName;
	if (k.length > 0) {
		return '<a class="New_Button" href="javascript:void(0);"  onclick="MessageFormHandler.findReply();">查看</a>';
	} else {
		return "没有留言";
	}
}

function onauditRenderer(e) {
	var z = parseInt(e.row.bumState);
	if (z == 1) {
		return "<span class='icon-show-yes' style='cursor: pointer;' onclick='MessageHandler.changeState(0)'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
	} else {
		return "<span class='icon-show-no' style='cursor: pointer;' onclick='MessageHandler.changeState(1)'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
	}
}